/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gitee.fdc.web.ajax;

/**
 * 响应结果生成工具
 */
public class ResultGenerator {

    private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";

    public static Result genSuccessResult() {
        return new Result().setCode(ResultCode.SUCCESS).setMsg(DEFAULT_SUCCESS_MESSAGE);
    }

    public static Result genSuccessResult(String message) {
        return new Result().setCode(ResultCode.SUCCESS).setMsg(message);
    }

    public static Result genSuccessResult(String key, Object data) {
        return new Result().setCode(ResultCode.SUCCESS).setMsg(DEFAULT_SUCCESS_MESSAGE).add(key, data);
    }

    public static Result genFailResult(String message) {
        return new Result().setCode(ResultCode.FAIL).setMsg(message);
    }
}
